package io.github.uicdb.et.data;

import io.github.uicdb.et.ElementalTheory;
import io.github.uicdb.et.ModBlocks;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;
import net.neoforged.neoforge.client.model.generators.BlockStateProvider;
import net.neoforged.neoforge.client.model.generators.ModelFile;
import net.neoforged.neoforge.data.event.GatherDataEvent;

class ETBlockStateProvider extends BlockStateProvider {

    public ETBlockStateProvider(GatherDataEvent event) {
        super(event.getGenerator().getPackOutput(), ElementalTheory.MODID, event.getExistingFileHelper());
    }

    @Override
    protected void registerStatesAndModels() {
        {
            Block block = ModBlocks.CLOUD_BLOCK.get();
            var cloud = (ModelFile) this.models().cubeAll(this.key(block).getPath(), this.blockTexture(block)).renderType("translucent");
            simpleBlockWithItem(ModBlocks.CLOUD_BLOCK.get(), cloud);
            simpleBlockWithItem(ModBlocks.METAL_ORE.get(), cubeAll(ModBlocks.METAL_ORE.get()));
            logBlock(ModBlocks.WOOD_WOOD.get());
            simpleBlockItem(ModBlocks.WOOD_WOOD.get(), this.models().cubeColumn(this.name(block), this.extend(blockTexture(ModBlocks.WOOD_WOOD.get()), "_side"), this.extend(blockTexture(ModBlocks.WOOD_WOOD.get()), "_top")));
        }

    }

    private ResourceLocation extend(ResourceLocation rl, String suffix) {
        String var10000 = rl.getNamespace();
        String var10001 = rl.getPath();
        return ResourceLocation.fromNamespaceAndPath(var10000, var10001 + suffix);
    }

    private String name(Block block) {
        return this.key(block).getPath();
    }

    private ResourceLocation key(Block block) {
        return BuiltInRegistries.BLOCK.getKey(block);
    }
}
